Using a :default for file names on include templates in SMARTY 3 [closed]

Posted by Yohan Leafheart on Programmers See other posts from Programmers or by Yohan Leafheart
Published on 2011-02-04T22:11:58Z Indexed on 2011/02/04 23:34 UTC
Read the original article Hit count: 399

Filed under:
|
|

Hello everyone,

Although I don't think the question was as good as it could be, let me try to explain better here.

I have a site using SMARTY 3 as the template system. I have a template structure similar to the below one:

/templates/place1/inner_a.tpl /templates/place1/inner_b.tpl

/templates/place2/inner_b.tpl /templates/place2/inner_c.tpl

/templates/default/inner_a.tpl /templates/default/inner_b.tpl /templates/default/inner_c.tpl

These are getting included on the parent template using {include file="{$temp_folder}/{$inner_template}"}

So far great. What I wanted to do is having a default for, in the case that the file "{$temp_folder}/{$inner_template}" does not exists, it uses the equivalent file at "default/{$inner_template}".

i.e. If I do {include file="place1/inner_c.tpl"}, since that file does not exists it in fact includes "default/inner_c.tpl"

Is it possible?

© Programmers or respective owner

Related posts about php

Related posts about templates